﻿using HDSmartCommunity.BUS;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;

namespace HDSmartCommunity.Models
{
    [Route("api/[controller]")]
    [ApiController]
    public class KoneVoltageController : ControllerBase
    {
        private readonly IHostingEnvironment _hostingEnvironment;
        public KoneVoltageController(IHostingEnvironment hostingEnvironment)
        {
            _hostingEnvironment = hostingEnvironment;
        }

        [HttpPost]
        [Route("KoneVoltageDownLoadLog")]
        public ResponseMessage KoneVoltageDownLoadLog(string StartTime, string EndTime, string NumberNo, string Type)
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                LogBUS logBUS = new LogBUS();
                message.data = logBUS.KoneVoltageDownLoad(StartTime, EndTime, NumberNo, Type);
            }
            catch (Exception ex)
            {
                message.errcode = 1;
                message.errmsg = "失败";
            }

            return message;
        }

        [HttpPost]
        [Route("QueryKoneDevice")]
        public ResponseMessage QueryKoneDevice()
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                DeviceBUS deviceBUS = new DeviceBUS();
                message.data = deviceBUS.QueryAllKoneDevice();
            }
            catch (Exception ex)
            {
                message.errcode = 1;
                message.errmsg = "失败";
            }

            return message;
        }

        [HttpPost]
        [Route("ExportKoneVoltage")]
        public ResponseMessage ExportKoneVoltage(string StartTime, string EndTime, string NumberNo)
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                LogBUS logBUS = new LogBUS();
                message.data = logBUS.KoneVoltageData(StartTime, EndTime, NumberNo);
            }
            catch (Exception ex)
            {
                message.errcode = 1;
                message.errmsg = "失败";
            }

            return message;
        }
    }
}
